// 点击试卷后的缩略信息
<template>
  <div id="msg">
    <div class="title">
      <span>试卷列表</span>
      <span>/  {{this.paperData.course.courseName}}</span>
    </div>
    <div class="wrapper">
      <ul class="top">
        <li class="example">试卷编号: {{this.paperData.paperId}}</li>
        <li><i class="iconfont icon-pen-"></i></li>
        <li class="right">
          <div>
            <span class="count">总分</span>
            <span class="score">{{this.paperData.count}}</span>
          </div>
        </li>
      </ul>
      <ul class="bottom">
        <li>出卷老师: {{this.paperData.course.user.userName}}</li>
      </ul>
    </div>
    <div class="content">
      <el-collapse v-model="activeName" >
        <el-collapse-item class="header" name="0">
          <template slot="title" class="stitle" >
            <div class="title">
              <el-button type="primary" size="small">点击查看试题详情</el-button>
            </div>
          </template>
          <el-collapse class="inner">
            <el-collapse-item>
              <template slot="title" name="1">
                <div class="titlei">单选题 (共{{this.singlecount}}题 共计{{this.singlescorecount}}分)</div>
              </template>
              <div class="contenti">
                <ul class="question" v-for="(list, index) in choosesingle" :key="index">
                  <li>{{index+1}}. {{list.chooseName}} {{list.chooseScore}}分</li>
                </ul>
              </div>
            </el-collapse-item>
            <el-collapse-item>
              <template slot="title" name="1">
                <div class="titlei">多选题 (共{{this.multcount}}题 共计{{this.multscorecount}}分)</div>
              </template>
              <div class="contenti">
                <ul class="question" v-for="(list, index) in choosemult" :key="index">
                  <li>{{index+1}}. {{list.chooseName}} {{list.chooseScore}}分</li>
                </ul>
              </div>
            </el-collapse-item>
            <el-collapse-item>
              <template slot="title" name="3">
                <div class="titlei">判断题 (共{{this.judgecount}}题 共计{{this.judgescorecount}}分)</div>
              </template>
              <div class="contenti">
                <ul class="question" v-for="(list, index) in judge" :key="index">
                  <li>{{index+1}}. {{list.topicName}} {{list.topicScore}}分</li>
                </ul>
              </div>
            </el-collapse-item>
            <el-collapse-item>
              <template slot="title" name="2">
                <div class="titlei">填空题 (共{{this.insertcount}}题  共计{{this.insertscorecount}}分)</div>
              </template>
              <div class="contenti">
                <ul class="question" v-for="(list, index) in insert" :key="index">
                  <li>{{index+1}}. {{list.topicName}} {{list.topicScore}}分</li>
                </ul>
              </div>
            </el-collapse-item>
            <el-collapse-item>
              <template slot="title" name="3">
                <div class="titlei">综合题 (共{{this.objcount}}题 共计{{this.objscorecount}}分)</div>
              </template>
              <div class="contenti">
                <ul class="question" v-for="(list, index) in obj" :key="index">
                  <li>{{index+1}}. {{list.topicName}} {{list.topicScore}}分</li>
                </ul>
              </div>
            </el-collapse-item>
          </el-collapse>
        </el-collapse-item>
      </el-collapse>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      activeName: '0',  //默认打开序号
      paperData: { //考试信息
        course:{
          courseName:"",
          user:{
            userName:""
          }
        }
      },
      choosesingle:[],
      singlecount:0,
      singlescorecount:0,
      choosemult:[],
      multcount:0,
      multscorecount:0,
      insert:[],
      insertcount:0,
      insertscorecount:0,
      judge:[],
      judgecount:0,
      judgescorecount:0,
      obj:[],
      objcount:0,
      objscorecount:0,

    }
  },
  mounted() {
    this.init()
  },
  methods: {
    //初始化页面数据
    init() {
      let paperId = this.$route.query.paperId //获取路由传递过来的试卷编号
      this.$axios(`/api/getpaperbyid/${paperId}`).then(res => {  //通过examCode请求试卷详细信息
        console.log(res.data)
        this.paperData = {...res.data}
      })

      this.$axios(`/api/getpapertopicmult/${paperId}`).then(res =>{
        console.log(res.data)
        for(var i=0;i<res.data.length;i++){
          if(res.data[i].chooseType == 1){
            this.choosesingle.push(res.data[i])
            this.singlecount += 1
            this.singlescorecount += res.data[i].chooseScore
          }else{
            this.choosemult.push(res.data[i])
            this.multcount += 1
            this.multscorecount += res.data[i].chooseScore
          }
        }
      })

      this.$axios(`/api/getpapertopicsingle/${paperId}`).then(res =>{
        console.log(res.data)
        for(var i=0;i<res.data.length;i++){
          if(res.data[i].topicType == 1){
            this.judge.push(res.data[i])
            this.judgecount += 1
            this.judgescorecount += res.data[i].topicScore
          }else if(res.data[i].topicType == 2){
            this.insert.push(res.data[i])
            this.insertcount += 1
            this.insertscorecount += res.data[i].topicScore
          }else{
            this.obj.push(res.data[i])
            this.objcount += 1
            this.objscorecount += res.data[i].topicScore
          }
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.bottom {
  .right{
    .el-button{
      color: #409EFF;
      border-color: #c6e2ff;
      background-color: #ecf5ff;
    }
  }
}
.right {
  margin-left: auto;
}
.inner .contenti .question {
  margin-left: 40px;
  color: #9a9a9a;
  font-size: 14px;
}
.content .inner .titlei {
  margin-left: 20px;
  font-size: 16px;
  color: #88949b;
  font-weight: bold;
}
.content .title .time {
  font-size: 16px;
  margin-left: 420px;
  color: #999;
}
.content .stitle {
  background-color: #0195ff;
}
.content .title span {
  margin-right: 10px;
}
#msg .content .title {
  font-size: 20px;
  margin: 0px;
  display: flex;
  align-items: center;
}
.content {
  margin-top: 20px;
  background-color: #fff;
}
.content .header {
  padding: 10px 30px;
}
.wrapper .info {
  margin: 20px 0px 0px 20px;
  border-top: 1px solid #eee;
  padding: 20px 0px 10px 0px;
}
.wrapper .info a {
  color: #88949b;
  font-size: 14px;
}
.wrapper .info a:hover {
  color: #0195ff;
}
.wrapper .bottom .btn {
  cursor: pointer;
  padding: 5px 10px;
  border: 1px solid #88949b;
  border-radius: 4px;
}
.wrapper .bottom {
  display: flex;
  margin-left: 20px;
  color: #999;
  font-size: 14px;
  align-items: center;
}
.wrapper .bottom li {
  margin-right: 14px;
}
#msg {
  background-color: #eee;
  width: 980px;
  margin: 0 auto;
}
#msg .title {
  margin: 7px 10px;
}
#msg .wrapper {
  background-color: #fff;
  padding: 10px;
}
.wrapper .top {
  display: flex;
  margin: 20px;
  align-items: center;
}
.wrapper .top .right {
  margin-left: auto;
}
.wrapper .top .example {
  color: #333;
  font-size: 22px;
  font-weight: 700;
}
.wrapper .top li i {
  margin-left: 20px;
  color: #88949b;
}
.wrapper .right .count {
  margin-right: 60px;
  color: #fff;
  padding: 4px 10px;
  background-color: #88949b;
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
  border: 1px solid #88949b;
}
.wrapper .right .score {
  position: absolute;
  left: 53px;
  top: -5px;
  padding: 1px 12px;
  font-size: 20px;
  color: #88949b;
  border: 1px dashed #88949b;
  border-left: none;
  border-top-right-radius: 4px;
  border-bottom-right-radius: 4px;
  font-weight: bold;
}
.wrapper .right div {
  position: relative;
}
</style>
